package com.example.kafka;

import com.example.kafka.producer.KafkaProducer;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.ConfigurableApplicationContext;

@SpringBootApplication
@MapperScan("com.example.kafka.dao")
public class KafkaApplication {

    public static void main(String[] args) {
        ConfigurableApplicationContext context = SpringApplication.run(KafkaApplication.class, args);
        KafkaProducer producer = context.getBean(KafkaProducer.class);

        for (int i = 0; i < 3; i++) {
            //调用消息发送类中的消息发送方法
            producer.send();
            try {
                Thread.sleep(300000);
            } catch (InterruptedException e) {
                e.printStackTrace();
            }
        }

    }

}
